package org.abacus.dbtojava;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class Config {
	public static final String MODEL = "model";
	public static final String DAO = "dao";
	public static final String PK = "pk";
	public static final String DB_TO_JAVA = "db-to-java.properties";
	public static final String DAO_TEMPLATE = "dao.template";
	public static final String DAO_IMPL_TEMPLATE = "dao-impl.template";
	public static final String SERVICE_TEMPLATE = "service.template";
	public static final String SERVICE_IMPL_TEMPLATE = "service-impl.template";
	public static final String HBM_XML_TEMPLATE = "hbm.xml.template";
	public static final String ID_HBM_XML_TEMPLATE = "id.hbm.xml.template";
	public static final String COMPOSITE_ID_HBM_XML_TEMPLATE = "composite-id.hbm.xml.template";

	public static final String CONFIG = "config.properties";
	public static final String DRIVER_CLASS_NAME = "driverClassName";
	public static final String USERNAME = "username";
	public static final String PASSWORD = "password";
	public static final String URL = "url";
	public static final String[] TABLE_NAME_TYPES = new String[] { "TABLE" };
	public static final int TABLE_NAME_INDEX = 3;
	public static final int TABLE_COLUMN_INDEX = 4;
	public static final String FILE_ENCODING = "UTF-8";
	public static final String NEW_LINE = "\n";
	public static final String SPACE = " ";
	public static final String TAB = "\t";
	public static final String SEMICOLON = ";";
	public static final String COMMA = ",";
	public static final String COLUMN_NAME = "COLUMN_NAME";
	public static final String COLUMN_TYPE = "COLUMN_TYPE";
	public static final String IS_AUTOINCREMENT = "IS_AUTOINCREMENT";
	public static final int TABLE_COLUMN_TYPE = 5;
	public static final int TABLE_COLUMN_IS_AUTOINCREMENT = 23;
	public static final String GETTER = "get";
	public static final String SETTER = "set";
	public static final String RETURNS = "return";

	private static Properties props;
	static {
		props = new Properties();
		InputStream inStream = Config.class.getResourceAsStream("/" + CONFIG);
		try {
			props.load(inStream);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static final String getString(String key) {
		Object value = props.get(key);
		if (value == null) {
			return null;
		}
		return value.toString();
	}

}
